package io;

import java.io.*;

/**
 * 缓冲流：是一对高级流，作用加快读写速率
 * 1）BufferedInputStream:缓冲流
 */

public class CopyDemo3Buffered {
    public static void main(String[] args) throws IOException {
        FileInputStream fis=new FileInputStream("1.jpg");
        BufferedInputStream bis=new BufferedInputStream(fis);
        FileOutputStream fos=new FileOutputStream("1_copy.jpg");
        BufferedOutputStream bos=new BufferedOutputStream(fos);
        long start=System.currentTimeMillis();
        int d;
        while ((d=bis.read())!=-1){//使用缓冲流读取字节

            bos.write(d);//使用缓冲流写出字节
        }
        long ends=System.currentTimeMillis();
        System.out.println("写出完毕,耗时"+(ends-start));
        bis.close();
        bos.close();

    }
}
